package live.jialing.sip.contact.student.rest;

import live.jialing.core.web.controller.SimpleBaseRestController;
import live.jialing.sip.base.domain.Student;
import live.jialing.sip.contact.student.domain.StudentGroup;
import live.jialing.sip.contact.student.service.StudentContactListService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 家校通讯录的API
 */
@RestController
@RequestMapping(value = "/contact/student/groups")
public class StudentContactListRestController extends SimpleBaseRestController<StudentGroup, Long> {

    private static Logger logger = LoggerFactory.getLogger(StudentContactListRestController.class);

    @Resource
    private StudentContactListService studentContactListService;

    @Override
    public StudentContactListService getService() {
        return this.studentContactListService;
    }

    /**
     * 获取指定分组的所有学生
     *
     * @param groupId 分组id
     * @return 学生集合
     */
    @RequestMapping(value = "/{groupId}/students", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public List<Student> findStudentByGroup(@PathVariable("groupId") Long groupId) {

        return studentContactListService.findGroupStudentByGroupId(groupId);
    }

    /**
     * TODO 设置分组内的成员
     *
     * @param groupId    分组ID
     * @param studentIds 学生ID集合
     */
    @RequestMapping(value = "/{groupId}/students", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void setupStudent(@PathVariable("groupId") Long groupId, List<Long> studentIds) {

    }

}
